﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.VendorModelCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.VendorModelCommandHandler
{
	public class DeleteVendormodelCommandHandler : IRequestHandler<DeleteVendormodelCommand, Results<int>>
	{
		private readonly IVendorModelService _vendorModelService;
		/// <summary>
		/// 构造方法
		/// </summary>
		/// <param name="vendorModelService"></param>
		public DeleteVendormodelCommandHandler(IVendorModelService vendorModelService)
		{
			_vendorModelService = vendorModelService;
		}
		/// <summary>
		/// 供应商删除
		/// </summary>
		/// <param name="loginUserId">删除人</param>
		/// <param name="idList">删除id</param>
		/// <returns></returns>
		public async Task<Results<int>> Handle(DeleteVendormodelCommand request, CancellationToken cancellationToken)
		{
			var vendor = await _vendorModelService.DeleteVendormodels(request.idList.ToArray());
			return Results<int>.DataResult(vendor);
		}
	}
}
